#pragma once

#include "base/core/singleton.h"
#include "base/core/object_pool.h"
#include "base/core/csv_parser.h"
#include "Common/Timer/TimerAxis.h"
#include "ProtoBuffer/AllProtocol.h"
#include "Common/MessageDispatch/MessageDispatch.h"
#include "Common/Event/Event.h"
#include "Common/EventDefine.h"
#include "Common/ComTypeDefine.h"
#include "Common/AdventureDefine.h"
//奇遇管理
class AdventureMgr : public IEventExecuteSink, public ManualSingleton<AdventureMgr>
{
	friend class ManualSingleton<AdventureMgr>;

	typedef unordered_map<uint32_t, AdventureCfgInfo> AdventureCfgMap;
public:
	AdventureMgr();
	virtual ~AdventureMgr();
	bool Init();
	void UnInit();
	/////////////////////////////////  IEventExecuteSink  /////////////////////////////////////////
	virtual void OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);
public:
	//奇遇任务接取倒计时
	int32_t AdventureAcceptTime();
	//获取奇遇配置信息
	const AdventureCfgInfo *GetAdventureCfgInfo(uint32_t adventureId);
	//根据奇遇行为获取奇遇ID列表
	const SET_UINT32 *GetAdventureByAction(int32_t actionType);
	//是否是奇遇行为
	bool IsAdventureAction(int32_t actionType);
private:
	//加载配置
	bool LoadConfig(const char *szFileName);
	//解析行为
	bool ParseAction(ActionCfgInfo &action, string strParam, SActionParam &param);
	//更新奇遇行为和奇遇ID列表
	void UpdateActionAdventure(int32_t actionType,uint32_t adventureId);
private:
	int32_t m_adventureAcceptTime;		//奇遇任务接取倒计时
	AdventureCfgMap m_mapAdventureCfg;	//奇遇配置数据
	MAP_INT32_SET_UINT32 m_mapActionAdventureMap;//奇遇行为事件对应奇遇ID列表
};

#define g_MakeAdventureMgr() (AdventureMgr::Instance())
#define g_GetAdventureMgr()  (AdventureMgr::GetInstance())
#define g_DelAdventureMgr()  (AdventureMgr::Destroy())